<template>
  <view class="sys_dept_edit_container">
    <view class="example">
      <uni-forms ref="form" :model="form" labelWidth="80px">
            <uni-forms-item label="父部门id" name="parentId"  >
              <uni-easyinput v-model="form.parentId" placeholder="请输入父部门id" />
            </uni-forms-item>
            <uni-forms-item label="部门名称" name="deptName"  >
              <uni-easyinput v-model="form.deptName" placeholder="请输入部门名称" />
            </uni-forms-item>
            <uni-forms-item label="显示顺序" name="orderNum"  >
              <uni-easyinput v-model="form.orderNum" placeholder="请输入显示顺序" />
            </uni-forms-item>
            <uni-forms-item label="负责人" name="leader"  >
              <uni-easyinput v-model="form.leader" placeholder="请输入负责人" />
            </uni-forms-item>
            <uni-forms-item label="联系电话" name="phone"  >
              <uni-easyinput v-model="form.phone" placeholder="请输入联系电话" />
            </uni-forms-item>
            <uni-forms-item label="邮箱" name="email"  >
              <uni-easyinput v-model="form.email" placeholder="请输入邮箱" />
            </uni-forms-item>
            <uni-forms-item label="删除标志" name="delFlag"  >
              <uni-easyinput v-model="form.delFlag" placeholder="请输入删除标志" />
            </uni-forms-item>
      </uni-forms>
      <view class="button-group">
        <button type="default" style="padding:0 3em;font-size:14px"  class="button" @click="cancel">取消</button>
        <button type="primary" style="padding:0 3em;font-size:14px"  class="button" @click="submit">提交</button>
      </view>
    </view>
  </view>
</template>


<script>
import { updateDept,getDept,listDept } from "@/api/system/dept";
    import {getSelectDict} from "@/utils/dict";
export default {
  components: {
  },
  data() {
    return {
          //字典类型筛选options
    form: {},
    rules: {
      }
    }
  },
onLoad(option) {
      //字典类型查询
  //部门详细
  this.getDeptInfo(option.deptId);
},
  onReady() {
    this.$refs.form.setRules(this.rules)
  },
  methods: {
    /* 获取部门详情*/
    getDeptInfo(deptId) {
      getDept(deptId).then(response => {
        this.form = response.data;
      })
    },
/* 提交*/
submit() {
  this.$refs.form.validate().then(res => {
    updateDept(this.form).then(response => {
      this.$modal.msgSuccess("编辑成功")
      setTimeout(() => {
        // 返回到上一级父页面
        this.$tab.navigateBack();
      },500)
    })
  })
},
/* 取消*/
cancel(){
  this.$tab.navigateBack();
}
}
}
</script>

<style lang="scss">
  page {
    background-color: #ffffff;
  }

  .sys_dept_edit_container {
    .example {
      padding: 15px;
      background-color: #fff;
    }

    .button-group {
      margin-top: 15px;
      display: flex;
      justify-content: space-around;
    }
  }
</style>